package com.atguigu.activemq.spring;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

import javax.jms.TextMessage;

/**
 * @Auther 赵乾坤
 * @Date 2021-04-16 20:39
 */
@Service
public class SpringMQ_Prodce {

    @Autowired
    private JmsTemplate jmsTemplate;

    public static void main(String[] args) {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        SpringMQ_Prodce prodce = (SpringMQ_Prodce) ctx.getBean("springMQ_Prodce");

        prodce.jmsTemplate.send((session -> {
            TextMessage textMessage = session.createTextMessage("************Spring和ActiveMQ的整合case for topic222......");
            return textMessage;
        }));
        System.out.println("***************send task over");

    }
}
